<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Banner extends Model
{
    use SoftDeletes;

    public $table = 'banner';
    protected $dates = ['deleted_at'];

    protected $fillable = [
    	'id',
        'title',
        'class_id',
        'start_time',
        'end_time',
        'pic',
        'introduction',
        'activity_id',
        'status'
    ];

    public function getPicAttribute()
    {
        if (isset($this->attributes['pic'])) {
            return url($this->attributes['pic']);
        }
        return '';
    }

    public function Activity()
    {
        return $this->hasMany(Activity::class,'id','activity_id');
    }

    public function class()
    {
        return $this->hasOne(ActivityClassif::class,'id','class_id');
    }
}
